package net.zjitc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.zjitc.entity.Order;
import net.zjitc.entity.OrderGoods;
import net.zjitc.mapper.OrderGoodsMapper;
import net.zjitc.mapper.OrderMapper;
import net.zjitc.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class OrderImpl implements OrderService {
    @Autowired(required = false)
    private OrderMapper orderMapper;
    @Autowired(required = false)
    private OrderGoodsMapper orderGoodsMapper;



    @Override
    public Page<Order> selectPage(Integer pagenum, Integer pagesize) {
        Page<Order> page=new Page<>(pagenum,pagesize);
        page=orderMapper.selectPage(page,null);
        return page;
    }


    @Override
    public Order update(Integer id, Order order) {
        if (Integer.parseInt(order.getIs_send())==0){
            order.setIs_send("否");
        }
        else if (Integer.parseInt(order.getIs_send())==1){
            order.setIs_send("是");
        }
       order.setOrder_id(id);
       orderMapper.updateById(order);

        return findById(id);
    }

    @Override
    public Order findById(Integer id) {
        Order order = orderMapper.selectById(id);
        return order;
    }
}
